package com.ww.demo.controller;

import com.ww.demo.core.entity.UserInfo;
import com.ww.demo.core.entity.request.LoginParam;
import com.ww.demo.core.entity.response.LoginResult;
import com.ww.demo.core.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author liuqingwang
 * @date 2021/10/25 21:47
 */
@RestController
public class LoginController {

    @Autowired
    UserService userService;

    @PostMapping("/login/account")
    public LoginResult login(@Validated @RequestBody LoginParam param) {
        return userService.login(param.getAccount(), param.getPassword());
    }


    @GetMapping("/user/list")
    public List<UserInfo> list(@RequestParam(value = "pagenum") Integer pagenum, @RequestParam(value = "pagesize") Integer pagesize) {
       return userService.getUserList(pagenum - 1, pagesize);
    }
}
